<template>
  <!-- 将DOM元素渲染到指定容器内部去 -->
  <teleport to="#dialog">
    <div v-if="visible">
      <p>Dialog content...</p>
      <button>确定</button>
      <button @click="$emit('update:visible', false)">取消</button>
    </div>
  </teleport>
</template>

<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  name: "Dialog",
  props: {
    visible: {
      type: Boolean,
      required: true,
    },
  },
  emits: ["update:visible"],
});
</script>

<style></style>
